1. Field of the Invention
The present invention relates to a two-dimensional code recognition apparatus, for example, such as a two-dimensional code reading apparatus, and a two-dimensional code recognition method.
2. Description of the Related Art
An image recognition apparatus of this type reads an image including a rectangular two-dimensional code figure having data arranged in a matrix form whose at least two or four sides are straight lines or a figure similar to the two-dimensional code figure, and extracts to recognize the two-dimensional code figure or the figure similar to the two-dimensional code figure from the read image. Note that a figure similar to a two-dimensional code figure is an image obtained by, e.g., reading an IC element mounted on a printed board as a two-dimensional figure, and the like.
Such an image recognition apparatus detects the position of a target two-dimensional figure 2 to be extracted from a read two-dimensional image 1, as shown in FIG. 16A. The pattern matching method as disclosed in, e.g., Jpn. Pat. Applin. KOKOKU Publication No. 62-3475 is frequently employed for this position detection.
This pattern matching method uses a plurality of reference patterns 3 as shown in FIG. 16B. The two-dimensional image 1 is scanned using the reference patterns 3, the similarities of the reference patterns 3 are represented by numerical values, and a portion having the obtained numerical value close to the numerical value of the two-dimensional image 1 is extracted, thereby detecting the position of the target two-dimensional figure 2 to be extracted.
The outline edge tracing method as disclosed in, e.g., Jpn. Pat. Applin. KOKOKU Publication No. 1-35385 is also used well for this position detection.
This outline edge tracing method is a method of detecting features of the outline of a figure. As shown in FIG. 17, an edge between a black pixel portion 4 and a white pixel portion 5 is traced as indicated by a solid arrow 6 to detect the outline of the figure.
The pattern matching method described above is known as a very effective method as a method of extracting the target two-dimensional figure 2 from the two-dimensional image 1 having a certain feature. This method is also effective to extract a figure having a feature like a rectangular two-dimensional code figure having data arranged in a matrix form whose at least two sides are straight lines or four sides are straight lines. However, in reading an image, it is rare that the two-dimensional code figure is present always parallel to the two-dimensional image, as shown in FIG. 16A. In many cases, as shown in FIG. 18A, the two-dimensional code figure 2 is read to be inclined with respect to the two-dimensional image 1.
For this reason, to extract the two-dimensional code figure 2 by using the pattern matching method in practice, reference patterns 7 representing straight lines having various inclination angles are prepared, as shown in FIG. 18B. The two-dimensional image 1 is sequentially scanned to detect the position of the target two-dimensional figure 2, thus requiring a long period of time for extracting the figure.
The above outline edge tracing method, unlike the pattern matching method, has no problem in detecting the position of an inclined straight line. In addition, only a portion having a feature in a two-dimensional image is retrieved, thus requiring a relatively short period of time for extracting a figure. However, it is difficult to specify the start point for tracing an outline edge. Even if the start point can be obtained smoothly, when a figure having a defect 8, as shown in FIG. 19, is read, the defect 8 portion is traced as an outline, as indicated by an dotted arrow 9 in FIG. 19. An outline different from the original outline is undesirably recognized.